package com.yaorange.service.impl;

import com.yaorange.dao.CarMapper;
import com.yaorange.entity.Car;
import com.yaorange.service.CarService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class CarServiceImpl implements CarService {

    @Resource
    private CarMapper carMapper;

    //
    @Override
    public int update(Car car) {
        return carMapper.updateByPrimaryKeySelective(car);
    }

    //
    @Override
    public int addCar(Car car) {
        //新增并返回自增主键
        return carMapper.insertUseGeneratedKeys(car);
    }

    @Override
    public int delete(Integer carId) {
        return carMapper.deleteByPrimaryKey(carId);
    }


}
